package com.orange.cetback.controller.user;

import com.orange.cetback.common.context.BaseContext;
import com.orange.cetback.common.vo.Result;
import com.orange.cetback.pojo.entity.MedalLevel;
import com.orange.cetback.pojo.entity.UserCheckins;
import com.orange.cetback.service.UserCheckinsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户签到记录表 前端控制器
 * </p>
 *
 * @author chenenjun
 * @since 2025-02-21
 */
@Slf4j
@Tag(name = "用户签到记录表接口")
@RestController
@RequestMapping("/userApi/userCheckins")
public class UserCheckinsController {
    @Autowired
    private UserCheckinsService userCheckinsService;

    @Operation(summary = "查询签到记录")
    @GetMapping("/list")
    public Result<List<UserCheckins>> list() {
        //根据用户id查询签到记录
        List<UserCheckins> list = userCheckinsService.list(BaseContext.getCurrentId());
        return Result.success(list);
    }

    @Operation(summary = "用户签到")
    @GetMapping("/signIn")
    public Result<MedalLevel> signIn() {
        //根据用户id查询签到记录
        MedalLevel medalLevel = userCheckinsService.signIn(BaseContext.getCurrentId());
        return Result.success(medalLevel);
    }

}
